﻿using EasyHttp.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EasyPayDemo.WeiPay
{
    public abstract class IFunction
    {
        public abstract void Execute();

        public string HttpPost<T>(string Url, T data)
        {
            #region Http请求处理

            //https 访问问题 
            //ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 |(SecurityProtocolType)768 | (SecurityProtocolType)3072;

            HttpClient httpClient = new HttpClient(new EncoderDecoderConfiguration());

            //httpClient.Request.AcceptCharSet = "UTF-8";
            httpClient.Request.Accept = "application/json"; //application/json  //text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
            //httpClient.Request.AcceptCharSet = "utf-8";
            var response = httpClient.Post(Url, data, HttpContentTypes.ApplicationJson);
            var result = response.RawText;
            #endregion

            Console.WriteLine(string.Format("返回结果：[{0}]", result));
            return result;
        }
    }
}
